from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB

# 创建数据
texts = ["I love AI", "AI is awesome", "I hate AI"]
labels = [1, 1, 0]

# 特征提取
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(texts)

# 训练模型
model = MultinomialNB()
model.fit(X, labels)

# 预测
print("Prediction for 'AI is great':", model.predict(vectorizer.transform(["AI is great"])))